//
//  ViewController.m
//  轮播器封装
//
//  Created by 涂永江 on 2017/8/28.
//  Copyright © 2017年 涂永江. All rights reserved.
//

#import "ViewController.h"
#import "HMCycleImageView.h"
#import <Masonry/Masonry.h>

@interface ViewController () <HMCycleImageViewDataSource,HMCycleImageViewDelegate>

@property (strong, nonatomic)   HMCycleImageView        *cycleImageView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.cycleImageView = [HMCycleImageView new];
    self.cycleImageView.dataSource = self;
    self.cycleImageView.delegate = self;
    self.cycleImageView.currentPageControlColor = [UIColor orangeColor];
    [self.view addSubview:self.cycleImageView];
    [self.cycleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.view);
    }];
    
    [self.cycleImageView reloadData];
}


#pragma mark - HMCycleImageViewDataSource -
// 提供图片轮播器的数量
- (NSInteger)numberOfItemsInCycleImageView:(HMCycleImageView *)cycleImageView {
    return 5;
}

// 返回图片轮播器的图片地址
- (NSURL *)cycleImageView:(HMCycleImageView *)cycleImageView urlForImageViewAtIndex:(NSInteger)index {
    switch (index) {
        case 0:
            return [NSURL URLWithString:@"http://img1.3lian.com/2015/w23/27/d/25.jpg"];
            break;
            
        case 1:
            return [NSURL URLWithString:@"http://img4.duitang.com/uploads/item/201412/05/20141205191118_WRAfW.jpeg"];
            break;
            
        case 2:
            return [NSURL URLWithString:@"http://img4.duitang.com/uploads/blog/201404/26/20140426191356_NLK3j.thumb.700_0.png"];
            break;
            
        case 3:
            return [NSURL URLWithString:@"http://f.hiphotos.baidu.com/zhidao/pic/item/77094b36acaf2eddde258bfa8e1001e9380193c9.jpg"];
            break;
            
        case 4:
            return [NSURL URLWithString:@"http://img4.duitang.com/uploads/item/201406/11/20140611202123_J2Nji.jpeg"];
            break;
            
        default:
            break;
    }
    return nil;
}
@end
